/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Nathan
 */

import java.io.File;
import java.util.ArrayList;
import java.util.Scanner;

public class RunElevator {
    public static void main(String[] arg) {
        //try {
    	Scanner scan = new Scanner(System.in);
    	try{
            scan = new Scanner(new File("input.txt"));
    	}
    	catch(Exception e) {
    		
    	}
            ArrayList<Rider> riders = new ArrayList<>();
            ArrayList<Thread> riderThreads = new ArrayList<>();
            String line = scan.nextLine();
            String[] split = line.split(" ");
            int numFloors = Integer.parseInt(split[0]);
            int numElevators = Integer.parseInt(split[1]);
            int maxRiders = Integer.parseInt(split[2]);
            int numRiderThreads = Integer.parseInt(split[3]);
            int maxOccupancy = Integer.parseInt(split[4]);
            Building b = new Building(numFloors, numElevators, maxOccupancy);
            
            while (scan.hasNext()) {
                line = scan.nextLine();
                split = line.split(" ");
                int riderID = Integer.parseInt(split[0]);
                int currentFloor = Integer.parseInt(split[1]);
                int destFloor = Integer.parseInt(split[2]);
                riders.add(new Rider(b,riderID,currentFloor,destFloor));
                int numThread = riders.size()-1;
                riderThreads.add(new Thread(riders.get(numThread)));
                riderThreads.get(numThread).setName("T" + (numThread+1));
                riderThreads.get(numThread).start();
            }
        }
       // catch (Exception e) {
         //   System.out.println("No input file");
        //}
   // }
}